package com.zzxy.mybatis;

import com.zzxy.mybatis.entity.UserExample;
import com.zzxy.mybatis.mapper.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;

public class test04 {
    SqlSession session;

    @Before
    public void before() throws IOException{
        InputStream is= Resources.getResourceAsStream("SqlMapConfig.xml");
        SqlSessionFactory ssf=new SqlSessionFactoryBuilder().build(is);
        session= ssf.openSession();
    }
    @Test
    public void test1(){
//        UserExample userExample=new UserExample();
        UserMapper mapper=session.getMapper(UserMapper.class);
        System.out.println(mapper.selectByPrimaryKey(28));
    }
    @After
    public void after(){session.close();}

}
